local weijidao = fk.CreateSkill{
  name = "lzsj__weijidao",
  tags = { "Round" },
}

Fk:loadTranslationTable{
  ["lzsj__weijidao"] = "为己道",
  [":lzsj__weijidao"] = "轮次技，一名角色使用无花色牌后，你可摸一张牌，你使用过非转化牌的回合结束后，重置此技能。",
  ["@@weijidao-round"] = "为己道<font color=\"#E8251E\"><b>发动</b></font>",

  ["$lzsj__weijidao1"] = "当胡子靠狠，当大帅？靠妈了个巴子的算盘！",
  ["$lzsj__weijidao2"] = "修铁路收税？这叫江湖规矩！",
}

local U = require "packages/utility/utility"

weijidao:addEffect(fk.CardUseFinished, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(weijidao.name) and (data.card.color == Card.NoColor or data.card.suit == Card.NoSuit)
    and player:usedSkillTimes(weijidao.name, Player.HistoryRound) == 0
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, weijidao.name)
    player.room:addPlayerMark(player, "@@weijidao-round")
  end,
})

weijidao:addEffect(fk.TurnEnd, {
  can_refresh = function(self, event, target, player, data)
    if player:hasSkill(weijidao.name) and player:usedSkillTimes(weijidao.name, Player.HistoryRound) > 0 then
      return #player.room.logic:getEventsOfScope(GameEvent.UseCard, 1, function(e)
        return e.data.from == player and U.isPureCard(e.data.card)
      end, Player.HistoryTurn) > 0
    end
  end,
  on_refresh = function(self, event, target, player, data)
    player:setSkillUseHistory(weijidao.name, 0, Player.HistoryRound)
    player.room:setPlayerMark(player, "@@weijidao-round", 0)
  end,
})

return weijidao